package puzzle.hashikake.data;

import java.util.ArrayList;
import java.util.List;

import tomoto.assertion.ParamUtil;

public class HashiDef {
	public final int i;
	public final ShimaDef car;
	public final ShimaDef cdr;
	private List<HashiDef> m_crossings;
	
	public HashiDef(int index, ShimaDef car, ShimaDef cdr) {
		this.i = index;
		this.car = car;
		this.cdr = cdr;
		
		m_crossings = new ArrayList<HashiDef>();
	}
	
	public void addCrossing(HashiDef hashiDef) {
		m_crossings.add(hashiDef);
	}
	
	public List<HashiDef> getCrossings() {
		return m_crossings;
	}
	
	public ShimaDef getOppositeOf(ShimaDef shima) {
		if (shima == car) {
			return cdr;
		} else if (shima == cdr) {
			return car;
		} else {
			throw ParamUtil.fail();
		}
	}
}
